package com.newbingo.entity;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.persistence.Embeddable;

@Embeddable
public class Lottery {

	private int num;

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public Lottery(int num) {
		super();
		this.num = num;
	}

	public Lottery() {
		super();
	}

	public static List<Lottery> toLotteries(int[] nums) {
		List<Lottery> lotteries = new ArrayList<Lottery>();
		for (int n : nums) {
			lotteries.add(new Lottery(n));
		}
		return lotteries;
	}

	public static String toString(List<Lottery> lotteries) {
		String str = "";
		Iterator it = lotteries.iterator();
		if (it.hasNext()) {
			str += it.next();
		}
		return str;
	}

	public static void main(String[] args) {
		Lottery lo=new Lottery();
		int[] nums={1,2,2,2,2};
		List<Lottery> lott=toLotteries(nums);
       String sr=toString(lott);
       System.out.println(sr);
	}

	public String toString() {
		return String.valueOf(num);
	}

	public int hashCode() {
		return num;
	}

	public boolean equals(Object o) {
		if (o instanceof Lottery) {
			Lottery l = (Lottery) o;
			return (this.num == l.getNum());
		}
		return false;
	}
}
